#ifndef TERRAIN_H
#define TERRAIN_H

#include "common.h"
#include "singleton.h"

enum ETerranType
{
    eTerran_Flatland = 0,
    eTerran_Forest,
    eTerran_Desert,
    eTerran_Hills,
    eTerran_Mountain,
    eTerran_Marsh,
    eTerran_City,
    eTerran_Num,
};

struct SGridData
{
    SGridData()
    {
        gridType = 0;
    }
    uint8 gridType;
};

typedef SGridData * GridDatas;
class CTextureRender;

class CTerrain:public CSingleton<CTerrain>
{
    IMPLEMENT_SINGLETON(CTerrain);
public:
    bool SetDimension( uint32 sizex, uint32 sizey, bool keepOld );
    void SetGridTerrain( uint32 x, uint32 y, SGridData &data );
    SGridData *GetGrid( uint32 x, uint32 y );
    bool ValidCoord( uint32 x, uint32 y );
    void RandomTerrain( );
    void Render( );
    void SaveTerrainTileToFile( LPCTSTR dir );
    void Save( );
    void Load( );
private:
    GridDatas m_grids; 
    uint32 m_sizex;
    uint32 m_sizey;
    int m_terrainAlphaTexID;
    int m_terrainTexId;
};

#endif